package cn.iocoder.yudao.module.system.dal.mysql.examcontrolline;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.controller.admin.examcontrolline.vo.ExamControlLinePageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.examcontrolline.ExamControlLineDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 特控线配置 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface ExamControlLineMapper extends BaseMapperX<ExamControlLineDO> {

    default PageResult<ExamControlLineDO> selectPage(ExamControlLinePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ExamControlLineDO>()
                .eqIfPresent(ExamControlLineDO::getExamId, reqVO.getExamId())
                .likeIfPresent(ExamControlLineDO::getLineName, reqVO.getLineName())
                .eqIfPresent(ExamControlLineDO::getLineType, reqVO.getLineType())
                .eqIfPresent(ExamControlLineDO::getProvince, reqVO.getProvince())
                .eqIfPresent(ExamControlLineDO::getYear, reqVO.getYear())
                .betweenIfPresent(ExamControlLineDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ExamControlLineDO::getId));
    }

    default List<ExamControlLineDO> selectList(ExamControlLinePageReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ExamControlLineDO>()
                .eqIfPresent(ExamControlLineDO::getExamId, reqVO.getExamId())
                .likeIfPresent(ExamControlLineDO::getLineName, reqVO.getLineName())
                .eqIfPresent(ExamControlLineDO::getLineType, reqVO.getLineType())
                .eqIfPresent(ExamControlLineDO::getProvince, reqVO.getProvince())
                .eqIfPresent(ExamControlLineDO::getYear, reqVO.getYear())
                .betweenIfPresent(ExamControlLineDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ExamControlLineDO::getId));
    }

    default List<ExamControlLineDO> selectListByExamId(Long examId) {
        return selectList(ExamControlLineDO::getExamId, examId);
    }

    default ExamControlLineDO selectByExamIdAndLineType(Long examId, String lineType) {
        return selectOne(new LambdaQueryWrapperX<ExamControlLineDO>()
                .eq(ExamControlLineDO::getExamId, examId)
                .eq(ExamControlLineDO::getLineType, lineType));
    }

    default List<ExamControlLineDO> selectListByProvinceAndYear(String province, Integer year) {
        return selectList(new LambdaQueryWrapperX<ExamControlLineDO>()
                .eq(ExamControlLineDO::getProvince, province)
                .eq(ExamControlLineDO::getYear, year)
                .orderByDesc(ExamControlLineDO::getScoreLine));
    }

    default List<ExamControlLineDO> selectListByLineType(String lineType) {
        return selectList(ExamControlLineDO::getLineType, lineType);
    }

}